The Schematron (Schematron.com) differs from other schema languages in that it not based on grammars but instead on finding tree patterns in a parsed document. This approach is said to allow many kinds of structures to be represented which are inconvenient and difficult in grammar-based schema languages. The Schematron is said to allow the development and mixing two kinds of schemas: (a) report elements that allow diagnosing which variant of a language is being processed, and (b) assert elements that allow confirmation that a document conforms to a particular schema.
The Schematron is based on simple actions:
first, find context nodes in the document (typically an element) based on XPath path criteria; and
then, check to determine if some other XPath expressions are true, for each of the found context nodes.
An XML Path Language (XPath) expression uses a path notation, similar to those used in URLs, for addressing parts of an XML document. The expression is evaluated to yield an object of the node-set, Boolean, number, or string type. For example, the expression X/Y will return a node-set of the <Y> elements contained in the <X> elements, if such elements are declared in the source XML document.
Schematron is an example of a rule-based language that allows the specification of semantic constraints. Schematron is based on the tree pattern (XPath) and is capable of expressing constraints in ways that other XML schema languages, such as XSD Schema and DTD cannot, e.g., data values, (inter-)dependencies, co-constraints, data state transitions, etc. and business rules.
Extensible markup language (XML) schemas express shared vocabularies and enable machines to carry out human-defined rules. XML schemas provide a means for defining the structure, content and semantics of XML documents.
In a general sense an XML schema is a description of a type of XML document, typically expressed in terms of constraints on the structure and content of documents of that type, above and beyond the basic syntactical constraints imposed by XML itself. These constraints are generally expressed using some combination of grammatical rules governing the order of elements, Boolean predicates that the content must satisfy, data types governing the content of elements and attributes, and more specialized rules such as uniqueness and referential integrity constraints.
Languages have been developed specifically to express XML schemas. The Document Type Definition (DTD) language, which is native to the XML specification, is one such type of language. Two more expressive XML schema languages are XML Schema and RELAX.
The mechanism for associating an XML document with a schema varies according to the schema language. The association may be achieved via markup within the XML document itself, or via some external means.
Currently available languages for expressing XML schemas are deficient in certain respects, such as in providing an ability to employ a combination of syntactic and semantic constraints.